package com.matchmealpha;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CommentView extends LinearLayout implements OnClickListener {
	private TextView commUser;
	private TextView description;
	private int callerID;
	private Context context;

	public CommentView(Context context, Comment comm, int callerID) {
		super(context);
		this.context = context;
		this.callerID = callerID;
		/* inflating layout */
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		inflater.inflate(R.layout.comment_item_view, this, true);

		this.commUser = (TextView) this.findViewById(R.id.CommentItemUsername);
		this.description = (TextView) this
				.findViewById(R.id.CommentItemDescription);
		setComment(comm);
	}

	public void setComment(Comment c) {
		this.commUser.setText(c.getUserID());
		this.description.setText(c.getDescription());
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.CommentItemUsername:
			Intent intent5 = new Intent(this.context, TimelineActivity.class);
			intent5.putExtra("back", true);
			intent5.putExtra("callerID", this.callerID);
			intent5.putExtra("curruser", this.commUser.getText());
			View view5 = MatchMeTabWidget.getCurrGroup(this.callerID)
					.getLocalActivityManager().startActivity(
							"TimelineActivity",
							intent5.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
					.getDecorView();
			MatchMeTabWidget.myReplaceView(view5, this.callerID);
			break;
		}

	}
}
